package com.exam.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.exam.entity.ExamManage;
import com.exam.entity.RespPageBean;
import com.exam.service.IExamManageService;
import com.exam.util.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 考试管理表 前端控制器
 * </p>
 *
 * @author zyh
 * @since 2023-03-09
 */
@RestController
@RequestMapping("/exam")
public class ExamManageController {

    @Autowired
    private IExamManageService iExamManageService;


    @GetMapping
    public RespBean findAll(){
        System.out.println("不分页查询所有试卷");
        List<ExamManage> list = iExamManageService.list();
        return RespBean.success("查询成功",list);
    }


    @GetMapping("/{page}/{size}")
    public RespPageBean findAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size){
        return iExamManageService.getExamManageByPage(page,size);
    }

    @GetMapping("/{examCode}")
    public RespBean findAll(@PathVariable("examCode") Integer examCode){
        LambdaQueryWrapper<ExamManage> queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.eq(ExamManage::getExamCode,examCode);
        ExamManage one = iExamManageService.getOne(queryWrapper);
        return RespBean.success("请求成功",one);
    }




}
